package com.lwj.liwanjia.view.activity.work.shang_jia.spfabu;

import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.TextView;

import com.lwj.liwanjia.R;
import com.lwj.liwanjia.adapter.fabu.FabuPsAdapter;
import com.lwj.liwanjia.base.BaseActivity;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;
import com.superrecycleview.superlibrary.recycleview.SuperRecyclerView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 选择列表
 */
public class ListActivity extends BaseActivity {

    @BindView(R.id.tv_left)
    TextView tvLeft;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.rl_select)
    SuperRecyclerView rlSelect;

    private FabuPsAdapter adapter;
    private List<String> list = new ArrayList<>();

    @Override
    protected void initView() {
        tvLeft.setVisibility(View.VISIBLE);
        tvTitle.setText("配送方式");
        LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        rlSelect.setLayoutManager(manager);
        rlSelect.setRefreshEnabled(false);
        rlSelect.setLoadMoreEnabled(false);
        adapter = new FabuPsAdapter(this, list);
        rlSelect.setAdapter(adapter);
        listener();
    }

    private void listener() {
        adapter.setOnItemClickListener(new SuperBaseAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, Object item, int position) {
                Intent intent = new Intent();
                intent.putExtra("fangshi", list.get(position));
                setResult(RESULT_OK, intent);
                finish();
            }
        });
    }


    @Override
    protected void initData() {
        list.add("立马送");
        list.add("安心快递");
        list.add("第三方物流");
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_list;
    }

    @OnClick(R.id.tv_left)
    public void onViewClicked() {
        finish();
    }
}
